﻿namespace dogd
{
	using System;
	using System.Data;

	/// <summary>
	/// ColumnAttribute is used to declare a persistable property where the name
	/// is the name of the database column. See subclasses for some convenient
	/// uses.
	/// 
	/// [Table("Cat")]
	/// public class Cat
	/// {
	///		[Column("Breed")]
	///		public string BreedName { get; set; }
	/// }
	/// 
	/// </summary>
	[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes", Justification = "Required base for DateTimeColumnAttribute etc.")]
	[AttributeUsage(AttributeTargets.Property)]
	public class ColumnAttribute : Attribute
	{
		/// <summary>
		/// Initializes ColumnAttribute with the name of the column in the database.
		/// Assumes storage type is string.
		/// </summary>
		/// <param name="columnName"></param>
		public ColumnAttribute(string columnName)
			: base()
		{
			this.ColumnName = columnName;
			this.StorageType = DbType.String;
		}

		/// <summary>
		/// The column name.
		/// </summary>
		public string ColumnName
		{
			get;
			private set;
		}

		/// <summary>
		/// The type of the data in the database.
		/// </summary>
		public DbType StorageType
		{
			get;
			set;
		}

		/// <summary>
		/// Whether this column will be used for lookups.
		/// </summary>
		public bool IsLookup
		{
			get;
			set;
		}

		/// <summary>
		/// Whether this column is a primary key
		/// </summary>
		public bool IsPrimaryKey
		{
			get;
			set;
		}

		/// <summary>
		/// Whether this column is a foreign key
		/// </summary>
		public bool IsForeignKey
		{
			get;
			set;
		}
	}
}
